home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Multiple R184024152001.psc / chatroomserver.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-04-15  |  5.2 KB  |  182 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
  4. Begin VB.Form Form1 
  5.    BorderStyle     =   3  'Fixed Dialog
  6.    Caption         =   "Chat Room Server"
  7.    ClientHeight    =   4935
  8.    ClientLeft      =   45
  9.    ClientTop       =   330
  10.    ClientWidth     =   8655
  11.    Icon            =   "chatroomserver.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   4935
  16.    ScaleWidth      =   8655
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin MSWinsockLib.Winsock host 
  19.       Index           =   0
  20.       Left            =   6480
  21.       Top             =   4680
  22.       _ExtentX        =   741
  23.       _ExtentY        =   741
  24.       _Version        =   393216
  25.    End
  26.    Begin VB.ListBox List3 
  27.       Height          =   4740
  28.       Left            =   6600
  29.       TabIndex        =   3
  30.       Top             =   120
  31.       Width           =   495
  32.    End
  33.    Begin VB.ListBox List2 
  34.       Height          =   4740
  35.       Left            =   5280
  36.       TabIndex        =   2
  37.       Top             =   120
  38.       Width           =   1335
  39.    End
  40.    Begin VB.ListBox List1 
  41.       Height          =   4740
  42.       Left            =   7200
  43.       TabIndex        =   1
  44.       Top             =   120
  45.       Width           =   1335
  46.    End
  47.    Begin RichTextLib.RichTextBox RichTextBox1 
  48.       Height          =   4740
  49.       Left            =   120
  50.       TabIndex        =   0
  51.       Top             =   120
  52.       Width           =   5055
  53.       _ExtentX        =   8916
  54.       _ExtentY        =   8361
  55.       _Version        =   393217
  56.       ReadOnly        =   -1  'True
  57.       ScrollBars      =   2
  58.       TextRTF         =   $"chatroomserver.frx":08CA
  59.    End
  60. Attribute VB_Name = "Form1"
  61. Attribute VB_GlobalNameSpace = False
  62. Attribute VB_Creatable = False
  63. Attribute VB_PredeclaredId = True
  64. Attribute VB_Exposed = False
  65. Private Sub Form_Load()
  66. host(0).Close
  67. host(0).LocalPort = 5678
  68. host(0).Listen
  69. msg "Host " & host(0).LocalIP & " hosting on port " & host(0).LocalPort, vbRed
  70. chans(0).chan = "main"
  71. chans(0).users = 0
  72. refreshlist
  73. End Sub
  74. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  75. sendall "dis "
  76. End Sub
  77. Private Sub host_Close(Index As Integer)
  78. On Error Resume Next
  79. For i = 0 To List1.ListCount - 1
  80.     If List1.List(i) = user(Index).un Then
  81.                 remnickfromchan Index
  82.                 DoEvents
  83.                 user(Index).un = ""
  84.                 user(Index).chan = ""
  85.                 user(Index).ListIndex = 0
  86.                 List1.RemoveItem i
  87.                 msg "User " & host(Index).RemoteHostIP & " disconnected at " & Format(Time, "HH:MM:SS AM/PM"), vbBlue
  88.     End If
  89. Next i
  90.         
  91. End Sub
  92. Private Sub host_ConnectionRequest(Index As Integer, ByVal requestID As Long)
  93. On Error GoTo hell:
  94. Dim d As Integer
  95. If NuM = 0 Then
  96. NuM = 1
  97. Load host(NuM)
  98. host(NuM).Accept requestID
  99. msg "User " & host(Index).RemoteHostIP & " connected at " & Format(Time, "HH:MM:SS AM/PM"), vbBlue
  100. Exit Sub
  101. End If
  102. For d = 1 To NuM
  103.     If host(d).State <> 7 Then
  104.         host(d).Close
  105.         host(d).Accept requestID
  106.         msg "User " & host(d).RemoteHostIP & " connected at " & Format(Time, "HH:MM:SS AM/PM"), vbBlue
  107.         Exit Sub
  108.     End If
  109. Next d
  110. If NuM = 1000 Then Exit Sub
  111. NuM = NuM + 1
  112. Load host(NuM)
  113. host(NuM).Accept requestID
  114. msg "User " & host(Index).RemoteHostIP & " connected at " & Format(Time, "HH:MM:SS AM/PM"), vbBlue
  115. hell:
  116. End Sub
  117. Private Sub host_DataArrival(Index As Integer, ByVal bytesTotal As Long)
  118. Dim strdata As String
  119. strdata = ""
  120. If host(Index).State <> 7 Then Exit Sub
  121. host(Index).GetData strdata
  122. cmd$ = Left(strdata, 4)
  123. If user(Index).un = "" Then
  124. msg host(Index).RemoteHostIP & ": " & strdata, vbBlue
  125. msg user(Index).un & ": " & strdata, vbBlue
  126. End If
  127. If Len(strdata) > 5 Then rest$ = Right(strdata, Len(strdata) - 4)
  128. rest$ = Trim(rest$)
  129. If cmd$ = "100 " Then
  130.     send Index, "220 "
  131. End If
  132. If cmd$ = "user" Then
  133.     For i = 0 To List1.ListCount - 1
  134.     If rest$ = List1.List(i) Then
  135.         send Index, "310 User name already in use."
  136.         host(Index).Close
  137.         Exit Sub
  138.     End If
  139.     Next i
  140.     user(Index).un = rest$
  141.     List1.AddItem rest$
  142.     send Index, "300 User name accepted."
  143. End If
  144. If cmd$ = "chnl" Then
  145.     Sendchans Index
  146. End If
  147. If cmd$ = "join" Then
  148.     If rest$ = user(Index).chan Then
  149.         send Index, "510 " & user(Index).un & " is already located in " & user(Index).chan & "."
  150.         Exit Sub
  151.     End If
  152.     addnicktochan Index, rest$
  153.     send Index, "500 "
  154. End If
  155. If cmd$ = "leav" Then
  156. Dim t As Integer
  157. t = Index
  158.     remnickfromchan Index
  159. End If
  160. If cmd$ = "list" Then
  161.     send Index, "lst " & chans(user(Index).ListIndex).uns
  162. End If
  163. If cmd$ = "msg " Then
  164.     sendmsginchan Index, strdata
  165. End If
  166. If cmd$ = "cre " Then
  167.     If addchan(rest$) = False Then
  168.         send Index, "710 Channel already created."
  169.     Else
  170.         send Index, "700 Channel created."
  171.         refreshlist
  172.     End If
  173. End If
  174. If cmd$ = "snd " Then
  175. DoEvents
  176.     sendmsginchan Index, "600 " & rest$
  177. End If
  178. If cmd$ = "900 " Then
  179.     senduserlist Index
  180. End If
  181. End Sub
  182.